/* 
 * File:   main.cpp
 * Author: chb
 *
 * Created on 4. September 2009, 20:57
 */

#include <stdlib.h>
#include <iostream>
#include "View.h"
#include "Controller.h"
#include "Map.h"
#include "Hero.h"

using namespace std;

int main(int argc, char** argv) {
    cout << "try to init sdl..." << endl;
    cout << getenv("PWD") << endl;
    View *v = View::instance();
    Controller *c = Controller::instance();

    Map *m = new Map();

    m->createMapSite(0, 0, MapSite::MS_TILE);
    m->createMapSite(1, 0, MapSite::MS_TILE);
    m->createMapSite(0, 1, MapSite::MS_TILE);
    m->createMapSite(1, 1, MapSite::MS_TILE);
    m->createMapSite(1, 2, MapSite::MS_TILE);
    m->createMapSite(2, 2, MapSite::MS_TILE);
    m->createMapSite(2, 3, MapSite::MS_TILE);
    m->createMapSite(3, 3, MapSite::MS_TILE);
    m->createMapSite(1, 3, MapSite::MS_TILE);
    m->createMapSite(0, 3, MapSite::MS_TILE);
    m->createMapSite(3, 1, MapSite::MS_TILE);
    m->createMapSite(3, 2, MapSite::MS_TILE);
    m->createMapSite(3, 3, MapSite::MS_TILE);

    m->createMapSite(0, 2, MapSite::MS_WALL);
    m->createMapSite(2, 0, MapSite::MS_WALL);
    m->createMapSite(3, 0, MapSite::MS_WALL);
    m->createMapSite(4, 0, MapSite::MS_WALL);
    m->createMapSite(4, 1, MapSite::MS_WALL);
    m->createMapSite(4, 2, MapSite::MS_WALL);
    m->createMapSite(4, 3, MapSite::MS_WALL);
    m->createMapSite(1, 4, MapSite::MS_WALL);
    m->createMapSite(2, 4, MapSite::MS_WALL);
    m->createMapSite(3, 4, MapSite::MS_WALL);
    m->createMapSite(4, 4, MapSite::MS_WALL);

    m->createMapSite(0, 4, MapSite::MS_DOOR);
    m->createMapSite(2, 1, MapSite::MS_DOOR);

    m->createMapSite(0, 5, MapSite::MS_TILE);
    m->createMapSite(0, 6, MapSite::MS_TILE);
    
    m->createMapSite(0, 7, MapSite::MS_WALL);
    m->createMapSite(1, 5, MapSite::MS_WALL);
    m->createMapSite(1, 6, MapSite::MS_WALL);
    m->createMapSite(1, 7, MapSite::MS_WALL);

    Hero *h = Hero::instance();

    m->getMapSite(0, 0)->enter(h);

    c->setHero(h);

    m->paint(v);

    c->mainLoop();
    delete c;
    delete v;
}

